package com.joysuch.wwyt.datadump.biz.convertor;

import cn.zlg.common.datadump.annotation.DataDumpField;
import cn.zlg.common.datadump.convertor.FieldValueConvert;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;

/**
 * 描述：日期格式
 *
 * @author zhangcancan
 * @date 2023/5/12 18:52
 **/
@Component
public class DateToStringConvertor implements FieldValueConvert<Date, String> {

    @Override
    public String convert(Object bean, Date value, DataDumpField dataField) {

        if (Objects.isNull(value)) {
            return null;
        }

        return new SimpleDateFormat("yyyy-MM-dd").format(value);
    }
}
